//
//  EditArticleViewController.m
//  我的图书馆
//
//  Created by 孙  路 on 15-1-6.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "EditArticleViewController.h"
//自定义cell
#import "EditArticleTableViewCell.h"
//进入数据库
#import "HistoryModel.h"
#import "HistoryBace.h"
@interface EditArticleViewController ()

@end

@implementation EditArticleViewController
- (void)dealloc
{
    [_tableArray release];
    [_tableV release];
    [super dealloc];
}
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.tableArray = [NSMutableArray array];

        self.tableV = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height - 64 - 49) style:UITableViewStyleGrouped];
        [_tableV registerClass:[EditArticleTableViewCell class] forCellReuseIdentifier:@"editingCell"];
        [_tableV setDelegate:self];
        [_tableV setDataSource:self];
        [self.view addSubview:_tableV];
        [_tableV release];
        [self readData];
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];

    [self createNavigation];
    [self createTabBar];
}
#pragma mark -
#pragma mark 读取数据库
- (void)readData
{

}
#pragma mark -
#pragma mark 自定义Navigation
- (void)createNavigation
{
    UIView *aView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 64)];
    [aView setBackgroundColor:[UIColor orangeColor]];

    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeSystem];
    [backButton setFrame:CGRectMake(10, 27, 30, 30)];
    [backButton addTarget:self action:@selector(backToTheLibrary:) forControlEvents:UIControlEventTouchUpInside];
    [backButton setImage:[UIImage imageNamed:@"iconfont-fanhui.png"] forState:UIControlStateNormal];

    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(self.view.frame.size.width / 2 - 70, 27, 140, 30)];
    [label setText:@"编辑我的收藏"];
    [label setTextAlignment:NSTextAlignmentCenter];
    [aView addSubview:label];
    [label release];

    [aView addSubview:backButton];
    [self.view addSubview:aView];
    [aView release];
}
- (void)backToTheLibrary:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}
#pragma mark -
#pragma mark 底边选项及相应触发事件(移动,删除)
- (void)createTabBar
{
//    UIView *bView = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 49, self.view.frame.size.width, 49)];
//    [bView setBackgroundColor:[UIColor orangeColor]];
//
//    UIButton *moveButton = [UIButton buttonWithType:UIButtonTypeSystem];
//    [moveButton setFrame:CGRectMake(30, 10, 60, 29)];
//    [moveButton addTarget:self action:@selector(moveCell:) forControlEvents:UIControlEventTouchUpInside];
//    [moveButton setTitle:@"移动" forState:UIControlStateNormal];
//    [moveButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
//    [bView addSubview:moveButton];
//
//    UIButton *removeButton = [UIButton buttonWithType:UIButtonTypeSystem];
//    [removeButton setFrame:CGRectMake(280, 10, 60, 29)];
//    [removeButton addTarget:self action:@selector(removeCell:) forControlEvents:UIControlEventTouchUpInside];
//    [removeButton setTitle:@"删除" forState:UIControlStateNormal];
//    [removeButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
//    [bView addSubview:removeButton];
//
//    [self.view addSubview:bView];
//    [bView release];
//}
//- (void)removeCell:(id)sender
//{
//
//}
//- (void)moveCell:(id)sender
//{
//
}
#pragma mark -
#pragma mark cell编辑
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [_tableArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    EditArticleTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"editingCell"];
    //cell.selectionStyle = UITableViewCellSelectionStyleBlue;
    cell.titleLabel.text = [NSString stringWithFormat:@"%ld", indexPath.row];
    return cell;
}

#pragma mark -
#pragma mark cell选择触发事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

}
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
